package imclient.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import org.qiyu.live.im.core.server.common.ImMsg;


/**
 * 类功能描述：
 *
 * @author 张广焱
 * @date 2023-12-03  16:15:02
 */
public class ClientHandler extends ChannelInboundHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        ImMsg imMsg = (ImMsg) msg;
        System.out.println("【服务端响应数据】result is " + imMsg);
//        if (imMsg.getCode() == ImMsgCodeEnum.IM_BIZ_MSG.getCode()) {
//            ImMsgBody respBody = JSON.parseObject(new String(imMsg.getBody()), ImMsgBody.class);
//            ImMsgBody ackBody = new ImMsgBody();
//            ackBody.setMsgId(respBody.getMsgId());
//            ackBody.setAppId(respBody.getAppId());
//            ackBody.setUserId(respBody.getUserId());
//            ImMsg ackMsg = ImMsg.build(ImMsgCodeEnum.IM_ACK_MSG.getCode(), JSON.toJSONString(ackBody));
//            ctx.writeAndFlush(ackMsg);
//        }
//        System.out.println("【服务端响应数据】result is " + new String(imMsg.getBody()));
    }
}
